package com.zx._12_算法;


import java.util.ArrayList;
import java.util.List;

public class LinkNode {

    public int data;
    public LinkNode next;

    public static LinkNode getNodes(Integer... nums) {
        LinkNode result = new LinkNode();
        result.data = nums[0];

        LinkNode node = result;
        for (int i = 1; i < nums.length; i++) {
            LinkNode node2 = new LinkNode();
            node2.data = nums[i];
            node.next = node2;
            node = node2;
        }
        return result;
    }

    public void print() {
        LinkNode head = this;
        List<Integer> resList = new ArrayList<>();
        while (head != null) {
            resList.add(head.data);
            head = head.next;
        }
        System.out.println(resList);
    }

}
